import { ReactiveProperty } from './../rxjs/cc3/ReactiveProperty';
import { ReactiveCommand } from './../rxjs/cc3/ReactiveCommand';
import { BaseManager } from './../rxjs/cc3/BaseManager';

import { _decorator, Component, Node, color, director, System } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('UIManager')
class UIManager extends BaseManager {

    public static instance: UIManager;
    static ID = 'ui_system';
    get logColorOverride() { return color().fromHEX('#BBDDEE') };

    static registerSystem() {
        director.unregisterSystem(director.getSystem(UIManager.ID));
        director.registerSystem(UIManager.ID, uim, System.Priority.MEDIUM);
        uim.init();
    }

    onInitManager() {
        this.log('onInitManager', this.timestamp);
    }

    // 初始在场景中的panel需要
    registerInitWithScenePanelCommand = ReactiveCommand.Create<{ panelKey: string, node: Node }>();

    onPanelChangeCommand = ReactiveCommand.Create();
    standby = ReactiveProperty.Create(true);
}

globalThis.UIManager = UIManager;

export const uim = UIManager.instance = new UIManager();